Descarga la base de datos del bosque silverwoods:
Carga las librerias necesarias y ejecuta los comandos que describen los datos:
library(ggplot2)
library(plotly)
# setwd("~/parcial1")
names(clima)
## [1] "upper" "lower" "rain" "month" "yr"
attach(clima)
head(clima)
str(clima)
## 'data.frame': 6940 obs. of 5 variables:
## $ upper: num 10.8 10.5 7.5 6.5 10 8 5.8 2.8 -0.8 1.5 ...
## $ lower: num 6.5 4.5 -1 -3.3 5 3 -3.3 -5.5 -4.8 -1 ...
## $ rain : num 12.2 1.3 0.1 1.1 3.5 0.1 0 0 0 0 ...
## $ month: int 1 1 1 1 1 1 1 1 1 1 ...
## $ yr : int 1987 1987 1987 1987 1987 1987 1987 1987 1987 1987 ...
month<-factor(month)
attach(clima)
str(clima)
## 'data.frame': 6940 obs. of 5 variables:
## $ upper: num 10.8 10.5 7.5 6.5 10 8 5.8 2.8 -0.8 1.5 ...
## $ lower: num 6.5 4.5 -1 -3.3 5 3 -3.3 -5.5 -4.8 -1 ...
## $ rain : num 12.2 1.3 0.1 1.1 3.5 0.1 0 0 0 0 ...
## $ month: int 1 1 1 1 1 1 1 1 1 1 ...
## $ yr : int 1987 1987 1987 1987 1987 1987 1987 1987 1987 1987 ...
is.factor(month)
## [1] TRUE
Como es el clima en cada mes para los años
1987-2005 en el bosque silverwoods (temp maximas)
Que mes
#plot(month,upper)
q1 <- ggplot(clima, aes(month, upper, fill=factor(month) ))
q1 <- q1 + geom_boxplot() + xlab("") + theme(legend.position = "none")
ggplotly(q1)
enero <- subset(clima, yr == 2000 )
head(enero)
enero <- subset(enero, month == 1 )
tail(enero)
qenero <- ggplot(enero, aes(month, upper, fill=factor(month) ))
qenero <- qenero + geom_boxplot() + xlab("") + theme(legend.position = "none")
ggplotly(qenero)
clima2 <- subset(clima, month =="3")
attach(clima2)
yr<-factor(yr)
head(clima2)
q2 <- ggplot(clima2, aes(yr, lower , fill=factor(yr) ))
q2 <- q2 + geom_boxplot() + xlab("") + theme(legend.position = "none")
ggplotly(q2)
(med <- median(clima2$lower))
## [1] 3.3
(q3 <- q2 + geom_hline(aes(yintercept=med), color= 2))
quantile(clima2$lower)
## 0% 25% 50% 75% 100%
## -7.3 0.5 3.3 6.0 12.0
(pp <- ggplot(clima2, aes(month,lower, fill="red")) + geom_boxplot())
ggplotly(pp)
quantile(clima2$lower)#SOLO PARA EL MES 3
## 0% 25% 50% 75% 100%
## -7.3 0.5 3.3 6.0 12.0
d <- ggplot(clima2, aes(clima2$lower)) + geom_density(fill="slateblue")
d
## Warning: Use of `clima2$lower` is discouraged. Use `lower` instead.